package main

import (
	"fmt"
	"sync"
	"time"
)

var (
	SumMap= make(map[int]uint64)
	lock sync.Mutex
)
type task struct {
	n int
}

func main() {
	for i:=1; i<50; i++ {
		t:=&task{n: i}
		go jc(t)
	}
	time.Sleep(time.Second*3)
	lock.Lock()
	for k,v:=range SumMap{
		fmt.Println(k,v)
	}
	lock.Unlock()

}

func jc(q *task) {

	var sum uint64
	sum = 1
	for i :=1; i <= q.n;i++ {
		sum *= uint64(i)
	}
	lock.Lock()
	SumMap[q.n] = sum
	lock.Unlock()

}
